package org.hairball;

import org.hairball.analysis.ConstructorInjectionAnalyser;
import org.hairball.analysis.RelationshipAnalyser;
import org.hairball.analysis.SetterInjectionAnalyser;

public enum AnalysisType {
    SETTER_INJECTION("setterInjection", new SetterInjectionAnalyser()),
    CONSTRUCTOR_INJECTION("constructorInjection", new ConstructorInjectionAnalyser());

    private String displayName;
    private RelationshipAnalyser classAnalyser;
    public RelationshipAnalyser analyser;

    AnalysisType(String displayName, RelationshipAnalyser classAnalyser) {
        this.displayName = displayName;
        this.classAnalyser = classAnalyser;
    }

    public static AnalysisType getForDisplayName(String displayName) throws UnsupportedAnalysisType {
        if (SETTER_INJECTION.displayName.equals(displayName)) {
            return SETTER_INJECTION;
        } else if (CONSTRUCTOR_INJECTION.displayName.equals(displayName)) {
            return CONSTRUCTOR_INJECTION;
        } else {
            throw new UnsupportedAnalysisType(displayName);
        }
    }

    public RelationshipAnalyser getClassAnalyser() {
        return classAnalyser;
    }
}
